﻿using System;
using System.Globalization;
using System.Windows.Data;
using YWM;
using YWM.Localization;

namespace PLCWpfTest.Converters
{
    public class ByteToAlarmTypeStringConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                throw new ArgumentNullException("Value can not be null");
            }
            ILocalizationManager lang = YApp.Resolve<ILocalizationManager>();
            string alarmType;
            switch ((byte)value) {
                case 0:
                default:
                    alarmType = "消除";
                    break;
                case 1:
                    alarmType = "触发";
                    break;
            }

            return lang[alarmType];
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}
